module.exports = class extends require('egg').Controller {
  async sendsms() {
    const { ctx } = this;
    const { tel } = ctx.request.body;
    const data = await ctx.service.sms.create({ tel });

    ctx.helper.res({ data });
  }
  async checksms() {
    const { ctx } = this;
    const { tel, sms, parent_uid } = ctx.request.body;
    await ctx.service.sms.check({ tel, sms });

    // 登录
    const token = await ctx.service.user.sign({ tel, parent_uid, ip: ctx.ip });

    ctx.helper.res({ data: { token } });
  }
  async info() {
    const { ctx } = this;
    const uid = ctx.helper.getUser();
    const user = await ctx.service.user.info(uid);

    ctx.helper.res({ data: user });
  }
};
